//
//  RCReplyCell.m
//  RocketProject
//
//  Created by chen jiedan on 13-11-17.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCReplyCell.h"
#import "CommonDefines.h"
#import "UIColor-Expanded.h"
#import "UIImageView+WebCache.h"

#define kBGImageFile            @"image_discount_cell_bg.png"

@implementation RCReplyCell{
    UIImageView *_imgView;
    UILabel *_nameLabel;
    UILabel *_contentLabel;
    UILabel *_dateLabel;
    UIImageView  *horizonLine;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        UIImage *bgImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kBGImageFile ofType:nil]];
        [self setBackgroundColorWithImage:bgImage];
        self.backgroundColor = [UIColor clearColor];
        
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}



- (void) createPlaceHolder
{
    _imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 78, 74)];
    [self.contentView addSubview:_imgView];
    [_imgView release];
    
    
    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(95, 15, 210, 15)];
    [self.contentView addSubview:_nameLabel];
    _nameLabel.font = [UIFont fontWithName:kFontNameHeiti size:12];
    _nameLabel.textColor = kNormalHeadTextColor;
    [_nameLabel setBackgroundColor:[UIColor clearColor]];
    [_nameLabel release];
    
    _dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(95, 70, 100, 15)];
    [self.contentView addSubview:_dateLabel];
    _dateLabel.font = [UIFont fontWithName:kFontNameHeiti size:12];
    _dateLabel.textColor = kNormalTextColor;
    [_dateLabel setBackgroundColor:[UIColor clearColor]];
    [_dateLabel release];
    
    _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(95, 30, 200, 50)];
    [self.contentView addSubview:_contentLabel];
    _contentLabel.font = [UIFont fontWithName:kFontNameHeiti size:12];
    _contentLabel.textColor = kNormalTextColor;
    _contentLabel.numberOfLines = 0;
    [_contentLabel setBackgroundColor:[UIColor clearColor]];
    [_contentLabel release];
    
    
    horizonLine = [[UIImageView alloc]initWithFrame:CGRectMake(0, 89, 320, 1)];
    horizonLine.backgroundColor = [UIColor clearColor];
    [horizonLine setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image_line_type3.png" ofType:nil]]];
    [self.contentView addSubview:horizonLine];
    [horizonLine release];
    
}

- (void) bindData:(RCMessageReplyListItemDataModel *)item
{
    UIImage *img = [UIImage imageNamed:@"bg_noticeAvatar"];
    [_imgView setImageWithURL:[NSURL URLWithString:item.avatar] placeholderImage:img];
    
    _nameLabel.text = item.title;
    _contentLabel.text = item.content;
    _dateLabel.text = item.dateTime;
    
}


+ (CGFloat) cellHeight:(RCMessageReplyListItemDataModel *)item
{
    return 90;
}


@end
